var levelOrder = function(root) {
	let res = [];
	if (!root) return [];
	let queue = [root];
	while (queue.length) {
		let subRes = [];
		let len = queue.length;
		for (let i = 0; i < len; i++) {
			// 出队列
			let cur = queue.shift();
			subRes.push(cur.val);
			// 入队列
			if (cur.left) queue.push(cur.left);
			if (cur.right) queue.push(cur.right);
		}
		res.push(subRes);	
	}
	return res
};